package com.by.core.controller;

import com.by.core.bean.ResultBean;
import com.by.core.ex.BusinessException;
import com.by.core.ex.ValidateException;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author Hzy
 * @version 1.0
 * @date 2025/4/10  11:29
 * @description
 * @since jdk11
 */
public class GlobalExceptionController extends BaseController{

    @ExceptionHandler(ValidateException.class)
    public ResultBean handleValidateException(ValidateException e) {
        return fail("验证失败",e.getErrorMap());
    }
    @ExceptionHandler(BusinessException.class)
    public ResultBean handleException(BusinessException e) {
        return fail("业务异常",e.getMessage());
    }
}
